package com.station.search.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.station.search.constant.DeleteEnum;
import com.station.search.domain.StationCheckRecord;
import com.station.search.mapper.StationCheckRecordMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: JT
 * @date: 2021/9/5
 * @Title:
 *          台站巡检记录业务层
 */
@Service
public class StationCheckRecordServiceImpl extends ServiceImpl<StationCheckRecordMapper, StationCheckRecord> implements StationCheckRecordService {

    @Resource
    private StationCheckRecordMapper stationCheckRecordMapper;

    @Override
    public List<StationCheckRecord> queryByStationId(String stationId) {
        Map<String, Object> queryParams = new HashMap<String, Object>(){{
            {
                put("STATION_CODE", stationId);
                put("IS_DELETE", DeleteEnum.NOT_DELETED.getValue());
            }
        }};
        return stationCheckRecordMapper.selectByMap(queryParams);
    }

    @Override
    public void deleteStationCheckRecordById(String recordId) {
        StationCheckRecord stationCheckRecord = new StationCheckRecord();
        stationCheckRecord.setId(recordId);
        stationCheckRecord.setIsDelete(DeleteEnum.IS_DELETED.getValue());
        stationCheckRecord.setDeleteDate(new Date());
        this.updateById(stationCheckRecord);
    }
}
